package cn.ulc.socket.weapp.service.impl;

import cn.ulc.common.constant.PubDataConstant;
import cn.ulc.common.constant.enums.AvailableStatus;
import cn.ulc.socket.weapp.common.BaseService;
import cn.ulc.socket.weapp.model.dto.AdvertisingListDTO;
import cn.ulc.socket.weapp.service.AdvertisingServ;
import cn.ulc.store.dao.AdvertisingDao;
import cn.ulc.store.dao.PubDataDao;
import cn.ulc.store.entity.Advertising;
import cn.ulc.store.entity.Company;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@AllArgsConstructor
public class AdvertisingServImpl extends BaseService implements AdvertisingServ {

    AdvertisingDao advertisingDao;
    PubDataDao pubDataDao;

    @Override
    public AdvertisingListDTO findTypeAdList() {
        Company company = getCurrentCompany();
        String code = pubDataDao.findCodeByTypeAndName(PubDataConstant.DATA_TYPE_AD_LOCATION,"分类页面顶部");
        List<Advertising> advertisingList = advertisingDao.findListByLocation(company.getId(),code,AvailableStatus.AVAILABLE);
        return new AdvertisingListDTO(advertisingList);
    }
}
